package com.techsun.json.format.defaultConfig.strategys;

import com.techsun.json.format.defaultConfig.data.constant.DefaultStrategyKeyConstant;
import com.techsun.json.format.defaultConfig.pattern.FormatPatternInterface;
import com.techsun.json.format.defaultConfig.util.InternationalFormatUtils;
import com.techusn.json.fromat.base.strategy.FormatStrategy;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @author chenYX
 * @date 2021/8/19 14:16
 * @description
 */
@Component
public class ShortDateStrategy implements FormatStrategy<String, Date> {

    @Resource
    private FormatPatternInterface formatPatternInterface;

    @Override
    public String getStrategyKey() {
        return DefaultStrategyKeyConstant.SHORT_DATE;
    }

    @Override
    public String formatData(Date value, String[] attach) {
        String shortPattern = formatPatternInterface.getShortPattern();
        return InternationalFormatUtils.formatShortDate(value, shortPattern);
    }
}
